package Proxy;

/**静态代理
 *
 * 动态代理：
 * 1.jdk动态代理
 * 2.CGlib动态代理
 *
 * 静态代理：
 * @author ChenweiLin
 * @create 2022-02-19 17:10
 */
public class StaticProxy {
    public static void main(String[] args) {
        Lawyer lawyer = new Lawyer();
        lawyer.speak();
    }
}

interface Speaker{
    void speak();
}

class Zhangsan implements Speaker{
    private String name;
    public Zhangsan() {
    }

    public Zhangsan(String name) {
        this.name = name;
    }

    @Override
    public void speak() {
        System.out.println("我是" + name + "，我老婆打我！");
    }
}

class Lawyer implements Speaker{
    private Zhangsan zhangsan  = new Zhangsan("张三");

    @Override
    public void speak() {
        System.out.println("引用法律条文！");
        zhangsan.speak();
        System.out.println("打人是不对的");
    }
}
